Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Data.SqlClient

  Public Class shipMethodClass 
    Inherits UserControl
  
    dim ConnStr as String
    Public ShipMethod as DropDownList
    Public SelectedMethod as Label
  
    Property ConnectionString() as String
    	Get
    		return ConnStr
    	end Get
    	
    	Set
    		ConnStr = value
    	end Set
    end Property
  
    Sub Page_Load(Source As Object, E As EventArgs)
  
      if not isPostBack
        Dim myConnection As SQLConnection
        Dim myCommand As SQLCommand
        Dim myReader  As SQLDataReader
        Dim SQL       As String
  
        SQl = "select * from Shippers"
        if ConnStr = "" then ConnStr = "server=localhost;uid=sa;pwd=;database=Northwind"
  
        myConnection = New SQLConnection(ConnStr)
        myConnection.Open()
  
        myCommand = New SQLCommand(SQL, myConnection)
  
        myReader = myCommand.ExecuteReader()
  
        While myReader.Read()
          ShipMethod.Items.Add(New ListItem(myReader.Item("CompanyName"), myReader.Item("ShipperID")))
        End While
      end if
    End Sub
    
    
    Sub ShipMethod_Change(Source As Object, E As EventArgs)
   	SelectedMethod.text = "You have selected " & ShipMethod.SelectedItem.Text & " as your shipping method." 
   
    End Sub
    
  End Class
